# Makefile  -*- Makefile -*-
# Copyright 2006 Nothing, Inc., All rights reserved.
#
# Epsilon Engine Library

# include directories
INCDIRS = -iquote.

LIBS = -framework Carbon -framework OpenGL -framework AGL

# optimizer flags
#OPT =				# no optimization or debugging
#OPT = $(OPT_DEBUG)		# debugging only
#OPT = $(OPT_OPT)		# standard optimization
#OPT = $(OPT_DEBUG) $(OPT_OPT)	# debugging and optimization
#OPT = $(OPT_MAXOPT)		# maximal optimization

# profiler flags
#PROF =				# no profiling
#PROF = $(PROF_ON)		# turn on profiling
#PROF = $(PROF_GPROF) 

# extra compiler definitions
XCPLUSDEFS = -fPIC

# source, object files
SRCS := $(wildcard *.cpp platform/MacOSX/*.cpp Epsilon3D/*.cpp EpsilonInput/*.cpp)
INLS := $(wildcard *.i)
#INCS := $(wildcard *.h) ### Not Ready For This Yet!
LOGS := $(patsubst %.log,"%.log" ,$(wildcard *.log))
OBJS := $(patsubst %.cpp,%.o,$(SRCS))

# target files
#LIB_TARGET := libepsilon.a
LIB_TARGET        := libEpsilon.a
#SHARED_LIB_TARGET := libepsilon.so
SHARED_LIB_TARGET := libEpsilon.dylib

# anything that this makefile can build
TARGETS := $(LOGS) $(OBJS) $(LIB_TARGET) $(SHARED_LIB_TARGET)

# all source files
SOURCES := $(SRCS) $(INCS) $(INLS)

# all doc files
DOCS := README

# standard Makefile targets

all: $(LOGS) $(LIB_TARGET) $(SHARED_LIB_TARGET)

checkin: checkin-local

clean: clean-local

depend: depend-local-c++

install: install-lib
 install-lib: $(SHARED_LIB_TARGET)
	@$(ECHO) " INSTALL lib   "; $(INSTALL) -m 0644 $(SHARED_LIB_TARGET) $(TOPDIR)/Dev $(LOG_MAKE)

$(LOGS):
	@$(RM) -f $@

.SUFFIXES: .cpp
.cpp.o::
	@$(LOG_CPP_HEADER)
	@$(ECHO) " CPP    $<"; $(CXX) $(CPLUSFLAGS) -c $< -o $@ $(LOG_COMPILE)
	@$(LOG_CPP_FOOTER)

$(LIB_TARGET):: $(OBJS)
	@$(RM) -f $@
	@$(ECHO) " AR     $@   " | $(TEE) -a link.log; $(AR)     $@ $(OBJS) $(LOG_LINK)
	@$(ECHO) " RANLIB $@   " | $(TEE) -a link.log; $(RANLIB) $@         $(LOG_LINK)

$(SHARED_LIB_TARGET): $(LIB_TARGET)
#	@$(ECHO) " LD     $(SHARED_LIB_TARGET)   " | $(TEE) -a link.log; $(LD) -shared -whole-archive $(LIB_TARGET) -o $(SHARED_LIB_TARGET) $(LOG_LINK)
#	gcc -shared -Wl,-soname,$@ -o $@ $(OBJS) -lc	### LINUX
# MacOS X
	g++ -dynamiclib $(OBJS) -o $@ $(LDFLAGS)


clean-local::
	@$(ECHO) " CLEAN   "; $(RM) -f $(TARGETS) Makefile.bak core[0-9]* *_pure_*.o *.s *~ $(LOG_MAKE);
	@if [ -f core ]; then $(RM) -f core; fi;

# get global rules
#include ../../Rules.make
include ../Rules.make

# include generated dependencies
-include .depend

# setup logging rules
include Rules.logs

